﻿using MediatR;
using SheepStorage.API.Application.Command.SheepMomHistoryCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepMomHistoryHandler
{
    public class ShowSheepMomHistoryCommandHandler : IRequestHandler<ShowSheepMomHistoryCommand, Results<List<SheepMomHistory>>>
    {
        ISheepMomHistoryService _res;

        public ShowSheepMomHistoryCommandHandler(ISheepMomHistoryService res)
        {
            _res = res;
        }

        public async Task<Results<List<SheepMomHistory>>> Handle(ShowSheepMomHistoryCommand request, CancellationToken cancellationToken)
        {
            var list =await _res.ShowSheepMomHistory(request.stadate, request.enddate, request.overbit);
            return Results<List<SheepMomHistory>>.DataResult(list);
        }
    }
}
